<html>
    <head>
        <style>
            body {
                padding: 0;
                margin: 0;
            }

            #box {
                width: 100px;
                height: 100px;
                background-color: #00cc88;
            }

            #size {
                height: 100px;
            }

            #overlay {
                background-color: black;
                position: sticky;
                top: 0px;
                height: 200px;
                width: 200px;
            }

            #trigger-overflow {
                width: 1px;
                height: 1px;
                position: absolute;
                top: 2000px;
                left: 2000px;
            }

            [data-layout-correct="false"] {
                background: #dd1144 !important;
                opacity: 0.5;
            }
        </style>
    </head>
    <body>
        <div id="size"></div>
        <div id="overlay">
            <div id="box"></div>
        </div>
        <div id="trigger-overflow"></div>

        <script type="module" src="/src/imports/projection.js"></script>
        <script type="module" src="/src/imports/script-assert.js"></script>
        <script type="module" src="/src/imports/script-undo.js"></script>
        <script type="module">
            const { createNode } = window.Undo
            const { matchViewportBox, addPageScroll } = window.Assert
            const { frame } = window.Projection

            const overlay = document.getElementById("overlay")
            const overlayProjection = createNode(overlay, undefined, {
                layoutRoot: true,
            })

            const box = document.getElementById("box")
            const boxProjection = createNode(box, overlayProjection)

            const scrollOffset = [50, 150]
            window.scrollTo(...scrollOffset)

            const boxOrigin = box.getBoundingClientRect()

            boxProjection.willUpdate()

            boxProjection.root.didUpdate()

            matchViewportBox(box, boxOrigin)
        </script>
    </body>
</html>
